package com.metagurukul.informer.service;

import java.sql.SQLException;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import com.metagurukul.informer.dao.AnswersDAO;
import com.metagurukul.informer.dao.QuestionsDAO;
import com.metagurukul.informer.valueObjects.Answers;
import com.metagurukul.informer.valueObjects.Questions;

public class ShowQuestionService {
	/**
	 * get the particular question with answer detail
	 * @param id
	 * @param request
	 * @return q
	 * @throws SQLException
	 */
	public boolean getData(String id, HttpServletRequest request)  throws SQLException{
		Questions question=new QuestionsDAO().findById(Integer.parseInt(id));	
		if(question==null){
			return false;
		}
		List<Answers> answers=new AnswersDAO().findById(Integer.parseInt(id));	
		request.setAttribute("question",question);
		request.setAttribute("answers",answers);
		return true;
	}
}
